from django.shortcuts import render
from django.http import HttpResponse
from .models import *


# Create your views here.

def login(request):
    return render(request, "user/login.html")


def login_handle(request):
    username = request.POST.get('Username')
    password = request.POST.get('Password')

    print('username:%s,password:%s' % (username, password))
    u = UserInfo.objects.filter(username__exact=username).first()
    # print(u)
    if u is not None:
        # print(u.password == password)
        if u.password == password:
            return render(request, 'main.html')
        else:
            return render(request, 'user/login.html')
    return render(request, 'user/login.html')
